package com.urea.web.controller.urea;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.urea.common.annotation.Log;
import com.urea.common.core.controller.BaseController;
import com.urea.common.core.domain.AjaxResult;
import com.urea.common.enums.BusinessType;
import com.urea.system.domain.TerminalCommLog;
import com.urea.system.service.ITerminalCommLogService;
import com.urea.common.utils.poi.ExcelUtil;
import com.urea.common.core.page.TableDataInfo;

/**
 * 终端通信日志Controller
 * 
 * @author liuzd
 * @date 2023-08-01
 */
@RestController
@RequestMapping("/terminal/comm/log")
public class TerminalCommLogController extends BaseController
{
    @Autowired
    private ITerminalCommLogService terminalCommLogService;

    /**
     * 查询终端通信日志列表
     */
    @PreAuthorize("@ss.hasPermi('terminal:comm:log:list')")
    @GetMapping("/list")
    public TableDataInfo list(TerminalCommLog terminalCommLog)
    {
        startPage();
        List<TerminalCommLog> list = terminalCommLogService.selectTerminalCommLogList(terminalCommLog);
        return getDataTable(list);
    }

    /**
     * 导出终端通信日志列表
     */
    @PreAuthorize("@ss.hasPermi('terminal:comm:log:export')")
    @Log(title = "终端通信日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TerminalCommLog terminalCommLog)
    {
        List<TerminalCommLog> list = terminalCommLogService.selectTerminalCommLogList(terminalCommLog);
        ExcelUtil<TerminalCommLog> util = new ExcelUtil<TerminalCommLog>(TerminalCommLog.class);
        util.exportExcel(response, list, "终端通信日志数据");
    }

    /**
     * 获取终端通信日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('terminal:comm:log:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(terminalCommLogService.selectTerminalCommLogById(id));
    }

    /**
     * 新增终端通信日志
     */
    @PreAuthorize("@ss.hasPermi('terminal:comm:log:add')")
    @Log(title = "终端通信日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TerminalCommLog terminalCommLog)
    {
        return toAjax(terminalCommLogService.insertTerminalCommLog(terminalCommLog));
    }

    /**
     * 修改终端通信日志
     */
    @PreAuthorize("@ss.hasPermi('terminal:comm:log:edit')")
    @Log(title = "终端通信日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TerminalCommLog terminalCommLog)
    {
        return toAjax(terminalCommLogService.updateTerminalCommLog(terminalCommLog));
    }

    /**
     * 删除终端通信日志
     */
    @PreAuthorize("@ss.hasPermi('terminal:comm:log:remove')")
    @Log(title = "终端通信日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(terminalCommLogService.deleteTerminalCommLogByIds(ids));
    }
}
